﻿@using NFine.Code
@{
    ViewBag.Title = "订单管理";
    Layout = "~/Views/Shared/_Index.cshtml";
    var _model = NFine.Code.OperatorProvider.Provider.GetCurrent();
    var _memberRole = Configs.GetValue("MemberRoleId");
    var _TransferRole = Configs.GetValue("TransferCenterRoleId");
}
<script src="~/Content/js/datepicker/WdatePicker.js"></script>
<script>
    var type = -1;
    $(function () {

        gridList(-1);
        $('#ulOrder a').click(function (e) {
            type = $(this).attr("type");
            $("#btn_search").click();
        });
    });
    function gridList(t) {
        type = t;
        var $gridList = $("#gridList");
        var postData = {
            Type: type,
            GiveTimeStart: $("#txt_startDate").val(),
            GiveTimeEnd: $("#txt_endDate").val()
        };
        $gridList.dataGrid({
            url: "/BizManage/UserGive/GetGridJson",
            postData: postData,
            height: $(window).height() - 128,
            multiselect: false,
            colModel: [
                { label: '主键', name: 'F_Id', hidden: true },
                { label: '赠送流水号', name: 'F_SerialNumber', width: 150, align: 'center' },
                { label: '赠送人', name: 'F_GiveUserName', width: 150, align: 'center' },
                { label: '收取人', name: 'F_ReceiveUserName', width: 150, align: 'center' },
                {
                    label: '赠送时间', name: 'F_GiveTime', width: 160, align: 'center'
                },
                {
                    label: '赠送积分数量', name: 'F_Money', width: 100, align: 'center',
                    formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == null ? "" : parseFloat(cellvalue).toFixed(2);
                    }
                },
                { label: '留言', name: 'F_Remark', width: 200, align: 'center' }

            ],
            pager: "#gridPager",
            sortname: 'F_GiveTime desc',
            viewrecords: true
        });
        $("#btn_search").click(function () {
            var postData = {
                Type: type,
                GiveTimeStart: $("#txt_startDate").val(),
                GiveTimeEnd: $("#txt_endDate").val()
            };
            $gridList.jqGrid('setGridParam', {
                postData: postData
            }).trigger('reloadGrid');
        });
    }
    

    function btn_add() {
        $.modalOpen({
            id: "Form",
            title: "赠送积分",
            url: "/BizManage/UserGive/Form",
            width: "500px",
            height: "350px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
            }
        });
    }
</script>

<div class="topPanel">
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_startDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="赠送日期" style="width: 150px;" />
                        --
                        <span style="float: right; margin-left: 3px;">
                            <input id="txt_endDate" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" placeholder="赠送日期" style="width: 150px;" />
                        </span>
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary" title="搜索">
                                <i class="fa fa-search"></i>
                            </button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        @if (_model != null)
        {
            if (_model.RoleId == _memberRole || _model.RoleId == _TransferRole)
            {
                <div class="btn-group">
                    <a id="NF-add" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>赠送</a>
                </div>
            }
        }
        
    </div>

</div>
<div class="tab-content content">
    <ul class="nav nav-tabs" role="tablist" id="ulOrder">
        <li role="presentation" class="active">
            <a href="#home" type="-1" id="ahome" aria-controls="home" role="tab" data-toggle="tab">全部记录</a>
        </li>
        @if (_model != null)
        {
            if (_model.RoleId == _memberRole || _model.RoleId == _TransferRole)
            {
                <li role="presentation">
                    <a href="#home" type="0" aria-controls="profile" role="tab" data-toggle="tab">赠送</a>
                </li>
                <li role="presentation">
                    <a href="#home" type="1" aria-controls="profile" role="tab" data-toggle="tab">收取</a>
                </li>
            }
        }
        
    </ul>
    <div role="tabpanel" class="tab-pane active " id="home">
        <div class="gridPanel tab-pane fade in active" id="baseInfo">
            <table id="gridList"></table>
            <div id="gridPager"></div>
        </div>
    </div>
</div>
